#include <Windows.h>
#include "semaphore.h"

HANDLE CreateSem (KEY key, int val, int maxVal)
{
		return CreateSemaphore(
	 	NULL,          
	 	val,          
	 	maxVal,       
	 	key);  
}

HANDLE OpenSem (KEY key)
{
	return OpenSemaphore(SEMAPHORE_ALL_ACCESS,FALSE, key);

}

void CloseSem (HANDLE hSem)
{
	CloseHandle(hSem);
}

void AcquireSem (HANDLE hSem)
{
	WaitForSingleObject(
 		hSem,  
 		0L);   
}

void ReleaseSem (HANDLE hSem)
{
	ReleaseSemaphore(
 	hSem,
 	1, 
 	NULL) ; 
}
